package com.java.threaddemo2;

public class Consumer implements Runnable {
	// 属性
	private WarehouseStack whStack;
	private boolean isStopped;// 多线程终止采用外部传入参数

	// 行为
	@Override
	public void run() {

		// while死循环
		while (true) {

			// 消费一个产品
			Product pro = whStack.pop();// 入栈
			System.out.println("消费产品信息：" + pro.printInfo());

			try {
				Thread.sleep(750);// 休眠1s
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	// 构造方法
	public Consumer(WarehouseStack whStack) {
		this.whStack = whStack;
	}

	// getter，setter

	public WarehouseStack getWhStack() {
		return whStack;
	}

	public void setWhStack(WarehouseStack whStack) {
		this.whStack = whStack;
	}

	public boolean isStopped() {
		return isStopped;
	}

	public void setStopped(boolean isStopped) {
		this.isStopped = isStopped;
	}

}
